package lion.workflow.handler;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import lion.framework.core.bean.BeanFactory;
import lion.workflow.IWorkflowHandler;

/**
 * 
 * 工作流 Handler管理器
 * 
 * @author lion
 * @email hl_0074@sina.com
 * @date 2014年8月27日
 */
public class WorkflowHandlers {

	private static Map<String, Class<IWorkflowHandler>> handlers = new HashMap<>();

	public static void regist(String name, Class<IWorkflowHandler> clazz) {

		handlers.put(name, clazz);
	}

	public static IWorkflowHandler getHandler(String name) {

		Class<IWorkflowHandler> clazz = handlers.get(name);
		if (clazz != null) { return BeanFactory.create(clazz); }

		return null;
	}

	public static Map<String, Class<IWorkflowHandler>> gethHandlers() {

		return Collections.unmodifiableMap(handlers);
	}
}
